package ch.ethz.fcl.metrobuzz;

import java.io.File;

import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.newdawn.slick.util.ResourceLoader;

public class MBProperty {
	public static boolean CONTROL_TIMEER = false;
	public static boolean CONTROL_TWL = false;

	// interchange visualization
	public static boolean REGIONS = false;
	public static boolean MRT = false;
	public static String INTERCHANGE_FOLDER;
	public static boolean SHOW_STATISTICS = false;

	public static boolean LOAD_PLAN = false;
	public static String PLAN_FILE = null;

	// accessibility visualization
	public static boolean ACCESSIBILITY = false;
	public static String EVENT_FILE = null;
	public static String WORK_FILE = null;
	public static boolean ACTIVITY = false;
	public static String POI_FILE_FOLDER = null;
	public static String RAW_FILE = null;
	
	// origin-destination visualization
	public static boolean OD = false;

	public static void read(String fileName) {
		PropertiesConfiguration prop = new PropertiesConfiguration();

		try {
			if (!new File(fileName).exists())
				fileName = fileName.replaceAll("properties/", "");

			// should use resource loader class for the jar file
			// load a properties file
			prop.load(ResourceLoader.getResourceAsStream(fileName));

			// get the property value and print it out
			ACCESSIBILITY = prop.getBoolean("accessibility");
			REGIONS = prop.getBoolean("multiscale_render");
			MRT = prop.getBoolean("mrt_render");
			CONTROL_TIMEER = prop.getBoolean("control_timer");
			CONTROL_TWL = prop.getBoolean("control_twl");
			INTERCHANGE_FOLDER = prop.getString("interchange_folder");
			SHOW_STATISTICS = prop.getBoolean("show_statistics");
			if (ACCESSIBILITY) {
				EVENT_FILE = prop.getString("event_file");
				WORK_FILE = prop.getString("work_file");
				ACTIVITY = prop.getBoolean("activity");
				POI_FILE_FOLDER = prop.getString("pois_file_folder");
			}

			RAW_FILE = prop.getString("raw_file");
			OD = prop.getBoolean("origin-destination");	

			LOAD_PLAN = prop.getBoolean("load_plan");
			if (LOAD_PLAN && (REGIONS || MRT))
				PLAN_FILE = prop.getString("plan_file");
		} catch (ConfigurationException e) {
			e.printStackTrace();
		}
	}
}